package TEST;

import java.util.Random;

public class Role {
    private String name;
    private int boold;
    private char gender;
    private String face;
    String[] boyfaces={"尖嘴猴腮","其貌不扬","贼眉鼠眼","獐头鼠目","仪表堂堂","唇红齿白"};
    String[] grilface={"美轮美奂","沉鱼落燕","婷婷玉立","惨不忍睹","面目狰狞"};

    public Role(){
    }
    public Role(String name, int boold,char gender) {
        this.name = name;
        this.boold = boold;
        this.gender = gender;
        setFace(gender);
    }
    public char getGender() {
        return gender;
    }
    public void setGender(char gender) {
        this.gender=gender;
    }
    public String getFace() {
        return face;
    }
    public void setFace(char gender) {
        Random r= new Random();
        if(gender=='男'){
            int index=r.nextInt(boyfaces.length);
            this.face=boyfaces[index];
        }else if(gender=='女'){
            int index=r.nextInt(grilface.length);
            this.face=grilface[index];
        }
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public int getBoold() {
        return boold;
    }
    public void setBoold(int boold) {
        this.boold = boold;
    }

    public void attack(Role role){
        Random r=new Random();
        int hurt = r.nextInt(40)+10;
        int remainBoold=role.getBoold()-hurt;
        remainBoold=remainBoold<0?0:remainBoold;
        role.setBoold(remainBoold);
        System.out.println(this.getName()+"打了"+role.getName()+"造成了"+hurt+"点伤害，"+role.getName()+"还剩下"+remainBoold+"点血");
    }


public void showRole(){
        System.out.println("姓名为："+getName());
    System.out.println("血量为："+getBoold());
    System.out.println("性别为："+getGender());
    System.out.println("长相为："+getFace());
}
}
